package com.service.gmall.Item;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author alpha
 * @className: Hello
 * @date 2022/9/5 13:23
 * @Description
 */
public class Hello {
    public List<String> test1(){
        return new ArrayList<>();
    }

    public Map<List<String>,String> test2(){
        return new HashMap<>();
    }
    @Test
    void test(){
        Hello hello = new Hello();
        Method[] methods = hello.getClass().getDeclaredMethods();
        for (Method method : methods) {
            String name = method.getName();
//            Class<?> type = method.getReturnType();
            Type type = method.getGenericReturnType();
            System.out.println(name + type);
        }
    }

    @Test
    void test01() throws JsonProcessingException {
        String json = "[\"1\",\"a\"]";
        ObjectMapper objectMapper = new ObjectMapper();
        List<String> list = objectMapper.readValue(json, new TypeReference<List<String>>() {});
        System.out.println("list = " + list);
    }
}